#include "FrequenceDecode.h"
#include "common.h"
#define FrequencyDecodeCycleTime	(1)
#define FrequencyDecodeEdgeType		(0)//0:上升沿 1：下降沿
#define FrequencyDecode1sCnt		(1000/FrequencyDecodeCycleTime)
structFrequencyDecode stFrequencyDecodeEgine={0};
void vFreqDecodeProc(void)//10ms
{
	UINT16 u16Temp;
	UINT16 i=0;
	stFrequencyDecodeEgine.u16EdgeCntArr[stFrequencyDecodeEgine.u8EdgeCntIndex++] = 
			stFrequencyDecodeEgine.u16_10ms_EdgeNumCnt;
	stFrequencyDecodeEgine.u16_100ms_EdgeNumCnt=0;
	if(stFrequencyDecodeEgine.u8EdgeCntIndex>=10)
		stFrequencyDecodeEgine.u8EdgeCntIndex=0;
	stFrequencyDecodeEgine.u16_10ms_EdgeNumCnt=0;
	u16Temp = 0;
	for(i=0;i<10;i++)
	{
		u16Temp =u16Temp +  stFrequencyDecodeEgine.u16EdgeCntArr[i];
	}
	if(u16Temp>6550)
	{
		u16Temp = 6550;
	}
	stFrequencyDecodeEgine.u16_100ms_EdgeNumCnt = u16Temp;
	stFrequencyDecodeEgine.u16Frequency = stFrequencyDecodeEgine.u16_100ms_EdgeNumCnt*10;
}
void vFreqDecodeIntterruptCallBack(void)//外部中断
{
	if((stFrequencyDecodeEgine.u16_10ms_EdgeNumCnt)<(655))
	{
		stFrequencyDecodeEgine.u16_10ms_EdgeNumCnt++;
	}
}

